<style>
	.toast {
		position: fixed;
		top: 20px;
		left: 50%;
		transform: translateX(-50%);
		background-color: #f08519;
		color: white;
		padding: 10px 20px;
		border-radius: 4px;
		font-size: 14px;
		display: none;
		z-index: 9999;
		box-shadow: 0 2px 6px rgba(0,0,0,0.2);
	}
</style>
<div id="toast" class="toast">✔ 复制成功!</div>
<div class="findtrs" >
	<form action="" class="layui-inline layui-form" method="post" style="width: 100%;">
		<div class="ftitle">
			<div class="lt">
				<h2>USDT 付款详情</h2>
			</div>
		</div>
		<div class="fremittanpred fbai" style="height: 1100px" >
			<div class="txt">
				<p style="font-size: 16px;color: red;font-weight: bold"><i class="layui-icon" style="font-size: 20px; ">&#xe60b;</i>  请支付与实际“到账数量”相符的金额(手续费自理),否则无法到账。</p>
				<p style="font-size: 16px;color: red;font-weight: bold"><i class="layui-icon" style="font-size: 20px; ">&#xe60b;</i>  请注意，仅接受USDT (TRC20)转账，转入非USDT(TRC20)将无法到账，造成资金损失。</p>
				{if $error_msg != ''}
				<p style="color: red;font-size: 20px;">Error : {$error_msg}。</p>
				{/if}
			</div>

			<div class="list">
				<ul>
					<li>
						<label style="font-size: 20px;width:800px;font-weight: bold">付款金额 USDT (TRC20) <img src="__STATIC__/lib/index/images/usdt.svg" style="height: 30px;width: 120px" alt="">
							<pre class="layui-code" style="font-size: 20px;width: 600px;"><i id="money_show">{$money}</i><span style="padding-left: 20px;">USDT</span><a id="copy-btn_money" href="javascript:;" style="color: #428bca;font-weight:normal;font-size: 15px;float: right" onclick="copyText('money_show')">Copy Text</a></pre>
						</label>
						<label style="font-size: 20px;width:800px;font-weight: bold">付款地址
							<pre class="layui-code" style="font-size: 20px;width: 600px;"><i id="address_show">{$address}</i><a id="copy-btn_user"  href="javascript:;" style="color: #428bca;font-weight:normal;font-size: 15px;float: right" onclick="copyText('address_show')">Copy Text</a></pre>
						</label>
					</li>
					<li></li>
					<li></li>
					</li>
					<li>
						{if $error_msg == ''}
					<li>
						<img id="oy_show" src="{$oy_show}" alt="" style="height: 200px;width: 200px;padding-left: 100px;">
					</li>
					{/if}
				</ul>
				{if $error_msg == ''}
				<ul>
					<li style="font-size: 20px;padding-left: 60px;width:800px;">
						请在:
						<strong id="hour_show"><s id="h"></s>0时</strong>
						<strong id="minute_show"><s></s>00分</strong>
						<strong id="second_show"><s></s>00秒</strong>
						内完成支付
					</li>
				</ul>
				{/if}
				<div class="txt">
					<p style="font-size: 13px;">1,此次充值完成会在余额内增加<span style="color: red">{$money_old}</span> USDT。</p>
					<p style="font-size: 13px;">2,请仔细核对<span style="color: red">转账地址</span>，如由于剪切板内容被篡改导致<span style="color: red">转账地址</span>错误,我司不承担损失。</p>
					<p style="font-size: 13px;">3,请在<span style="color: red">30分钟</span>内支付完成，否则<span style="color: red">订单失效</span>。</p>
					<p style="font-size: 13px;">4,订单超时<span style="color: red">请勿转账</span>,如由于超时转账导致资金损失，我司不承担损失。</p>
					<p style="font-size: 13px;">5,付款成功后，系统会在<span style="color: red">5分钟</span>内完成到账。</p>
					<p style="font-size: 13px;">6, 如果不小心支付了错误的金额，请点击<span style="color: red">"取消充值"</span>,然后选择<span style="color: red">"充值未到账"</span></p>
				</div>
			</div>

			<input type="hidden" id="out_trade_no" value="{$out_trade_no}">
			<div class="fbottonlst" style="float: left">
				<ul>
					<li><a href="{:url('fund/usdt')}">返回</a></li>
					<li><a href="{:url('fund/usdtCancel?otn=' . $out_trade_no)}">取消充值</a></li>
				</ul>
			</div>
		</div>
	</form>

</div>
<script type="text/javascript">
	var myTimer;
	var intDiff=1;
	$(document).ready(function() {
		index = setInterval("ajaxstatus()", 2000);

		const blog = "{$blog}";
		if(blog == 1){
			layer.msg("{$error_msg}", {time:1500} ,function () {
				window.location.href = "{:url('fund/usdt')}";
			});
		}

		// $("#copy-btn_money").click(function(){
		// 	copyText();
		// });
		// $("#copy-btn_user").click(function(){
		// 	var copyText2 = document.getElementById("address_show");
		// 	copyText2.focus();
		// 	// copyText2.select();
		// 	document.execCommand("copy");
		// 	alert("复制成功！");
		// });

	});

	function ajaxstatus() {
		if(intDiff>0){
			var date = new Date();
			var timer = date.getTime().toString();
			$.ajax({
				url:"{:url('oyCheckTrade')}?mcard=" + $('#out_trade_no').val() + "&t=" + timer,
				type: "GET",
				dataType: "json",
				success: function(res) {
					console.log(res.data.check);
					const check = res.data.check;

					if(check == 1) { //订单状态为1表示支付成功
						layer.msg('支付成功.' , {time:1500} , function () {
							window.location.href = "{:url('log')}";
						});

					}
					if(check == 2) { //订单状态为1表示支付成功
						layer.msg('支付失败，请稍后再尝试.' , {time:2000} , function () {
							window.location.href = "{:url('usdt')}";
						});

					}
					if(check == 3) { //订单状态为1表示支付成功
						layer.msg('支付已过期，请稍后再尝试.' , {time:2000} , function () {
							window.location.href = "{:url('usdt')}";
						});

					}
				},
				error: function() {

				}
			});
		}
	}
	function timer(intDiff) {
		myTimer = window.setInterval(function () {
			var day = 0,
					hour = 0,
					minute = 0,
					second = 0;//时间默认值
			if (intDiff > 0) {
				day = Math.floor(intDiff / (60 * 60 * 24));
				hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
				minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
				second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
			}
			if (minute <= 9) minute = '0' + minute;
			if (second <= 9) second = '0' + second;
			$('#hour_show').html('<s id="h"></s>' + hour + '时');
			$('#minute_show').html('<s></s>' + minute + '分');
			$('#second_show').html('<s></s>' + second + '秒');
			if (hour <= 0 && minute <= 0 && second <= 0) {
				intDiff = 0;
				window.location.href = "{:url('usdt')}";
				clearInterval(myTimer);
			}
			intDiff--;

		}, 2000);
	}

	function showToast(message) {
		const toast = document.getElementById('toast');
		toast.textContent = message;
		toast.style.display = 'block';
		setTimeout(() => {
			toast.style.display = 'none';
		}, 2000);
	}

	function copyText(elementId) {
		const textToCopy = document.getElementById(elementId).textContent;
		const textArea = document.createElement('textarea');
		textArea.value = textToCopy;
		document.body.appendChild(textArea);
		textArea.select();
		document.execCommand('copy');
		document.body.removeChild(textArea);
		showToast('已复制: ' + textToCopy);
	}
	$().ready(function() {
		timer("{$ht_time}");
	});
</script>